<?
include("../lib/config.php");
$username 	= $HTTP_GET_VARS['u'];
$op			= $HTTP_GET_VARS['op'];

if($op == "edit"){
	$Faction = "../lib/update.php";
	$Vbutton = "Update";
	$query	= mssql_query("SELECT * FROM S_User WHERE username='$username' ",$conn);
	$row	= mssql_fetch_array($query);
	$readonly = "readonly";
}
else{
	$Faction = "../lib/save.php";
	$Vbutton = "Save";
	$readonly = "";
}

include("../header.php");
?>
<script type="text/javascript">
	function Validate(){
		if(document.F.project_name.value == "")
		{
			alert("Field : Project Name tidak boleh kosong ...");
			document.F.project_name.focus();
			return false;
		}

		if(document.F.b1.value == "")
		{
			alert("Field : Bulan Awal Periode harus dipilih ...");
			document.F.b1.focus();
			return false;
		}
		
		if(document.F.t1.value == "")
		{
			alert("Field : Tahun Awal Periode harus dipilih ...");
			document.F.t1.focus();
			return false;
		}
		
		if(document.F.b2.value == "")
		{
			alert("Field : Bulan Akhir Periode harus dipilih ...");
			document.F.b2.focus();
			return false;
		}
		
		if(document.F.t2.value == "")
		{
			alert("Field : Tahun Akhir Periode harus dipilih ...");
			document.F.t2.focus();
			return false;
		}

		if(document.F.purpose.value == "")
		{
			alert("Field : Purpose tidak boleh kosong ...");
			document.F.purpose.focus();
			return false;
		}
		
		if(document.F.purpose.value == "")
		{
			alert("Field : Purpose tidak boleh kosong ...");
			document.F.purpose.focus();
			return false;
		}

		if(document.F.purpose.value == "")
		{
			alert("Field : Purpose tidak boleh kosong ...");
			document.F.purpose.focus();
			return false;
		}
		
		if(document.F.project_manager.value == "")
		{
			alert("Field : Project Manager tidak boleh kosong ...");
			document.F.project_manager.focus();
			return false;
		}		

		if(document.F.division.value == "")
		{
			alert("Field : Division tidak boleh kosong ...");
			document.F.division.focus();
			return false;
		}		
/*
		if(document.F.branch.value == "")
		{
			alert("Field : Branch tidak boleh kosong ...");
			document.F.branch.focus();
			return false;
		}		
*/		
		document.F.submit();
		
	}
</script>
</head>
<table width="100%" class="no_border">
 <tr>
  <td colspan="2">
	<table width="100%" style="border:none;">
	<tr>
	 <td colspan="2" class="line_bottom">&nbsp;&nbsp;<b>LOG BOOK DOWNLOAD CV ONLINE</b></td>
	</tr>
	<tr>
	</table>
  </td>
 </tr>
 <tr>
  <td>&nbsp;</td>
 </tr>
 <tr>
  <td>
  <?
	if($op == "edit"){
		$value="$row[username]";
	}
	else{
		$value="";			
	}
  ?>
  <form name="F" action="<?=$Faction?>" method="post">
     <table cellpadding="4" cellspacing="1" width="100%">
      <tr>
       <td colspan="2">
       <fieldset><legend>Silahkan Isi Form Dibawah ini sebelum men-download CV Karyawan</legend>
		<table>
         <tr>
          <td width="200">Nama Proyek/Pekerjaan</td>
          <td><input type="text" style="width:400px;" name="project_name" value="<?=$value?>" <?=$readonly?> /> <span class="required">*</span></td>
         </tr>
         <tr>
          <td>Periode Waktu</td>
          <td>
		  <select name="b1">
		   <option value="">--bulan-</option>
		   <option value="Jan">Januari</option>
		   <option value="Feb">Februari</option>
		   <option value="Mar">Maret</option>
		   <option value="Apr">April</option>
		   <option value="Mei">Mei</option>
		   <option value="Jun">Juni</option>
		   <option value="Jul">Juli</option>
		   <option value="Ags">Agustus</option>
		   <option value="Sep">September</option>
		   <option value="Okt">Oktober</option>
		   <option value="Nov">November</option>
		   <option value="Des">Desember</option>
		  </select>
		  <select name="t1">
		   <option value="">--tahun--</option>
		   <?
		   		$ta = date("Y");
		   		for($i=$ta;$i<=($ta+100);$i++){
					echo"<option value='$i'>$i</option>";
				}
		   ?>
		  </select>
		  &nbsp;&nbsp;-&nbsp;&nbsp; 
		  <select name="b2">
		   <option value="">--bulan-</option>
		   <option value="Jan">Januari</option>
		   <option value="Feb">Februari</option>
		   <option value="Mar">Maret</option>
		   <option value="Apr">April</option>
		   <option value="Mei">Mei</option>
		   <option value="Jun">Juni</option>
		   <option value="Jul">Juli</option>
		   <option value="Ags">Agustus</option>
		   <option value="Sep">September</option>
		   <option value="Okt">Oktober</option>
		   <option value="Nov">November</option>
		   <option value="Des">Desember</option>
		  </select>
		  <select name="t2">
		   <option value="">--tahun--</option>
		   <?
		   		$ta = date("Y");
		   		for($i=$ta;$i<=($ta+100);$i++){
					echo"<option value='$i'>$i</option>";
				}
		   ?>
		  </select>
		  <span class="required">*</span>
		  </td>
         </tr>
         <tr>
          <td valign="top">Untuk Keperluan/Tujuan</td>
          <td>
          <textarea style="width:400px; height:100px;" name="purpose"></textarea>
           <span class="required">*</span></td>
         </tr>
         <tr>
          <td>Project Manager</td>
          <td><input type="text" name="project_manager" size="65"/> <span class="required">*</span></td>
         </tr>         
         <tr>
          <td>Unit Kerja</td>
          <td><!--<input type="text" name="division" size="65"/> -->
			<select name="division">
          <option value="">--silahkan pilih--</option>
          <?
          		$sff = mssql_query("SELECT * FROM VLevelCabang WHERE status='1' ORDER BY uraian ASC");
				while($rff = mssql_fetch_array($sff)){
					echo"<option value='$rff[uraian]'>$rff[uraian]</option>";
				}
		  ?>
          </select>          <span class="required">*</span></td>
         </tr> 
         <!---                 
         <tr>
          <td>Cabang</td>
          <td><input type="text" name="branch" size="65"/> <span class="required">*</span></td>
         </tr>                           
         -->
		 <!--
         <tr>
          <td>Cabang</td>
          <td><select name="branch">
          <option value="">--silahkan pilih--</option>
          <?
          	//	$sfff = mssql_query("SELECT * FROM VCabang ORDER BY Nama ASC");
			//	while($rfff = mssql_fetch_array($sfff)){
			//		echo"<option value='$rfff[Nama]'>$rfff[Nama]</option>";
			//	}
		  ?>
          </select>
          
           <span class="required">*</span></td>
         </tr>   
		 -->                        
         <tr>
          <td>&nbsp;</td>
          <td><br />
          <input type="hidden" name="cat" value="log_cvonline" />
          <input type="button" class="button" value="Batal" onclick="Javascript:history.back();" /><input type="button" class="button" value="Kirim" onclick="Validate();" /> </td>
         </tr>
        </table>
       </fieldset>
       </td>
      </tr>
     </table>
     </form>
  </td>
</tr>
</table>
<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
